#include <stdio.h>
#include <stdlib.h>
int cmp(const void* e1, const void* e2)
{
    return (*(int*)e2 > *(int*)e1);
}
int thirdMax(int* nums, int numsSize)
{
    qsort(nums, numsSize, sizeof(int), cmp);
    if (numsSize < 3)
    {
        return nums[0];
    }
    else
    {
        int i = 0;
        int j = 1;
        for (i = 0; i < numsSize - 1; i++)
        {
            if (j == 3)
                break;
            if (nums[i + 1] != nums[i])
                j++;
        }
        if (j < 3)
            return nums[0];
        else
            return nums[i];
    }
}

int main()
{
    int nums[3] = { -2147483648,1,1 };
    int ans = thirdMax(nums, 3);
    printf("%d\n", ans);

	return 0;
}